package com.user.entity;


import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.user.entity.dto.StudentDTO;

@Entity
@Table(name="t_student")
public class Student {
	private Long id;
	private String name;
	private String num;
	private String sex;
	private Integer grade;
	private Department department;
	private String password;
	private boolean revoked;
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}
	public String getName() {
		return name;
	}
	public String getNum() {
		return num;
	}
	public String getSex() {
		return sex;
	}
	public Integer getGrade() {
		return grade;
	}
	@ManyToOne(fetch=FetchType.EAGER)
	public Department getDepartment() {
		return department;
	}
	public String getPassword() {
		return password;
	}
	
	public boolean isRevoked() {
		return revoked;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public void setName(String name) {
		this.name = name;
	}
	public void setNum(String num) {
		this.num = num;
	}
	public void setSex(String sex) {
		this.sex = sex;
	}
	public void setGrade(Integer grade) {
		this.grade = grade;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	
	public void setRevoked(boolean revoked) {
		this.revoked = revoked;
	}
	public Student() {
		super();
	}
	public Student(StudentDTO dto, Department department) {
		super();
		this.id = dto.getId();
		this.name = dto.getName();
		this.num = dto.getNum();
		this.sex = dto.getSex();
		this.grade = dto.getGrade();
		this.department = department;
		this.password = dto.getPassword();
	}
	@Override
	public String toString() {
		return "Student [id=" + id + ", name=" + name + ", num=" + num + ", sex=" + sex + ", grade=" + grade
				+ ", department=" + department + ", password=" + password + ", revoked=" + revoked + "]";
	}
	
}
